package ex204.shape;

public class Circle {
    private double x = 0.0;
    private double y = 0.0;
    private double radius = 1.0;

    public Circle() {
    }

    public Circle(double x, double y, double radius) {
        this.x = x;
        this.y = y;
        this.radius = radius;
    }

    // this 到 other 圆心的距离
    private double distanceTo(Circle other) {
        return Math.sqrt((this.x - other.x) * (this.x - other.x) + (this.y - other.y) * (this.y - other.y));
    }

    public boolean contains(Circle other) {
        return this.radius >= other.radius && (this.radius - other.radius) >= this.distanceTo(other);
    }

    public boolean intersects(Circle other) {
        return this.distanceTo(other) < (this.radius + other.radius) && this.distanceTo(other) > Math.abs(this.radius - other.radius);
    }

    public boolean separates(Circle other) {
        return this.distanceTo(other) >= (this.radius + other.radius);
    }

    public double getX() {
        return x;
    }

    public void setX(double x) {
        this.x = x;
    }

    public double getY() {
        return y;
    }

    public void setY(double y) {
        this.y = y;
    }

    public double getRadius() {
        return radius;
    }

    public void setRadius(double radius) {
        this.radius = radius;
    }
}
